import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
  IsArray,
  IsNotEmpty,
  IsNumber,
  IsOptional,
  IsString,
} from 'class-validator';
import { DictItem } from './dict-item.entity';

export class Dict {
  @ApiProperty({ description: '字典编码' })
  @IsNotEmpty({ message: '字典编码不能为空！' })
  code: string;
  @ApiProperty({ description: '字典名称' })
  @IsNotEmpty({ message: '字典名称不能为空！' })
  name: string;
  @ApiPropertyOptional()
  @IsString()
  remark?: string;
  @ApiPropertyOptional()
  @IsNumber()
  weight?: number;
  @ApiProperty({ description: '字典项', type: () => [DictItem] })
  @IsOptional()
  @IsArray()
  items?: DictItem[];
}
